<template>
  <div>
    <navbar class="navbar">
      <div slot="left" class="back" @click="backclick">
        <img src="~assets/img/common/back.svg" />
      </div>
      <div slot="cente" class="title">
        <div
          v-for="(itme, index) in titles"
          class="titleitme"
          :class="{ active: index === currentindex }"
          @click="timeclick(index)"
        >
          {{ itme }}
        </div>
      </div>
    </navbar>
  </div>
</template>

<script>
import navbar from "components/common/navbar/navbar";
export default {
  name: "detailnavbar",
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentindex: 0,
    };
  },
  components: {
    navbar,
  },
  methods: {
    timeclick(index) {
      this.currentindex = index;
      this.$emit("titleclick", index);
    },
    backclick() {
      this.$router.back();
    },
  },
};
</script>

<style>
.navbar {
  position: relative;
  z-index: 9;
  background-color: #fff;
}
.title {
  display: flex;
}
.titleitme {
  font-size: 12px;
  flex: 1;
}
.active {
  color: rgb(204, 62, 62);
}
.back img {
  margin-top: 12px;
}
</style>